<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>junglego: world.cpp Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">junglego
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.8.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">world.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="world_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &quot;<a class="code" href="creature_8hpp.html">creature.hpp</a>&quot;</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include &quot;<a class="code" href="gl_helper_8hpp.html">glHelper.hpp</a>&quot;</span>
<a name="l00003"></a>00003 <span class="preprocessor">#include &quot;<a class="code" href="world_8hpp.html">world.hpp</a>&quot;</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &quot;<a class="code" href="types_8hpp.html">types.hpp</a>&quot;</span>
<a name="l00005"></a>00005 
<a name="l00006"></a><a class="code" href="class_world.html#afa39d4e6f714a7a3691ac0c656f5e8a8">00006</a> <a class="code" href="class_world.html#afa39d4e6f714a7a3691ac0c656f5e8a8">World::World</a>() { }
<a name="l00007"></a>00007 
<a name="l00008"></a><a class="code" href="class_world.html#a8c73fba541a5817fff65147ba47cd827">00008</a> <a class="code" href="class_world.html#a8c73fba541a5817fff65147ba47cd827">World::~World</a>() { }
<a name="l00009"></a>00009 
<a name="l00010"></a><a class="code" href="class_world.html#a695e14e5574f9bbdf58c8f39538b11d3">00010</a> <span class="keywordtype">bool</span> <a class="code" href="class_world.html#a695e14e5574f9bbdf58c8f39538b11d3">World::init</a>(<a class="code" href="types_8hpp.html#a91ad9478d81a7aaf2593e8d9c3d06a14">uint</a> nCreature, <a class="code" href="types_8hpp.html#a91ad9478d81a7aaf2593e8d9c3d06a14">uint</a> nFood, <a class="code" href="types_8hpp.html#a91ad9478d81a7aaf2593e8d9c3d06a14">uint</a> xSize, <a class="code" href="types_8hpp.html#a91ad9478d81a7aaf2593e8d9c3d06a14">uint</a> ySize) {
<a name="l00011"></a>00011     <span class="comment">//srand(time(NULL));</span>
<a name="l00012"></a>00012     <a class="code" href="class_world.html#a42483905f9b8454a61292868d29a8843">m_nCreature</a> = nCreature;
<a name="l00013"></a>00013     <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a> = <span class="keyword">new</span> <a class="code" href="class_creature.html">Creature</a>[<a class="code" href="class_world.html#a42483905f9b8454a61292868d29a8843">m_nCreature</a>];
<a name="l00014"></a>00014     <a class="code" href="class_world.html#a189b065d93b1ec9055065fea18aa9961">m_xSize</a> = xSize;
<a name="l00015"></a>00015     <a class="code" href="class_world.html#a7e13242f5970ab45bd6b992c8987d972">m_ySize</a> = ySize;
<a name="l00016"></a>00016     <a class="code" href="class_world.html#a6bf5860fb9d8f404200592609206e216">m_xScr</a> = xSize/2;
<a name="l00017"></a>00017     <a class="code" href="class_world.html#a6b96ef9603bdd3c8bca55eb7e3ec88bd">m_yScr</a> = ySize/2;
<a name="l00018"></a>00018     <a class="code" href="class_world.html#a02f718296e4f2887157520a32c816751">m_scale</a> = 1;
<a name="l00019"></a>00019     <span class="keywordflow">for</span> (<a class="code" href="types_8hpp.html#a91ad9478d81a7aaf2593e8d9c3d06a14">uint</a> i = 0; i &lt; <a class="code" href="class_world.html#a42483905f9b8454a61292868d29a8843">m_nCreature</a>; i++) {
<a name="l00020"></a>00020         <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_creature.html#ae109a8875e1906f4ffee7bf3b8ba479c">init</a>(10,
<a name="l00021"></a>00021                           (<a class="code" href="structs__colour.html">s_colour</a>){(float)rand() / RAND_MAX, (float)rand() / RAND_MAX, (float)rand() / RAND_MAX},
<a name="l00022"></a>00022                           <span class="comment">/*</span>
<a name="l00023"></a>00023 <span class="comment">                          (s_vector){(i % 20) * 40 + 40, (i / 20) * 40 + 40},</span>
<a name="l00024"></a>00024 <span class="comment">                          (s_vector){0,0});</span>
<a name="l00025"></a>00025 <span class="comment">                          */</span>
<a name="l00026"></a>00026                           (<a class="code" href="structs__vector.html">s_vector</a>){rand() % <a class="code" href="class_world.html#a189b065d93b1ec9055065fea18aa9961">m_xSize</a>, rand() % <a class="code" href="class_world.html#a7e13242f5970ab45bd6b992c8987d972">m_ySize</a>},
<a name="l00027"></a>00027                           (<a class="code" href="structs__vector.html">s_vector</a>){rand() % 10 - 5, rand() % 10 - 5});
<a name="l00028"></a>00028                           <span class="comment">//*/</span>
<a name="l00029"></a>00029 <span class="preprocessor">#ifdef DBG</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span>        cout &lt;&lt; <span class="stringliteral">&quot;Making Creature &quot;</span> &lt;&lt; i &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt;
<a name="l00031"></a>00031                                 <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#af09fffca261588bbbffc8bbe83bab13f">getColour</a>()-&gt;<a class="code" href="structs__colour.html#a0fb80f5fa16ec787b61f782cb0ce1c98">r</a> &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt;
<a name="l00032"></a>00032                                 <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#af09fffca261588bbbffc8bbe83bab13f">getColour</a>()-&gt;<a class="code" href="structs__colour.html#a6d55099c8e1e3d82dd7532c4a4fe3289">g</a> &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt;
<a name="l00033"></a>00033                                 <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#af09fffca261588bbbffc8bbe83bab13f">getColour</a>()-&gt;<a class="code" href="structs__colour.html#a9c0662f4e0e31aad1ec0040568552994">b</a> &lt;&lt; <span class="stringliteral">&quot; | &quot;</span> &lt;&lt;
<a name="l00034"></a>00034                                 <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#ae41a90d5f2c9fb4a3252565396f6b738">getRadius</a>() &lt;&lt; <span class="stringliteral">&quot; | &quot;</span> &lt;&lt;
<a name="l00035"></a>00035                                 <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2372849d2bc4e337ccfc9b48236a3d3a">pos</a>.<a class="code" href="structs__vector.html#a5f391a150c90caba95e29898f47e4343">x</a> &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt;
<a name="l00036"></a>00036                                 <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2372849d2bc4e337ccfc9b48236a3d3a">pos</a>.<a class="code" href="structs__vector.html#a38d7ef8912bdd7a9146e6a560fe500d3">y</a> &lt;&lt; <span class="stringliteral">&quot; | &quot;</span> &lt;&lt;
<a name="l00037"></a>00037                                 <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2ec4f506d737782910bf9d161acbefa8">vel</a>.<a class="code" href="structs__vector.html#a5f391a150c90caba95e29898f47e4343">x</a> &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt;
<a name="l00038"></a>00038                                 <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2ec4f506d737782910bf9d161acbefa8">vel</a>.<a class="code" href="structs__vector.html#a38d7ef8912bdd7a9146e6a560fe500d3">y</a> &lt;&lt; <span class="stringliteral">&quot; &quot;</span> &lt;&lt;endl;
<a name="l00039"></a>00039 <span class="preprocessor">#endif</span>
<a name="l00040"></a>00040 <span class="preprocessor"></span>    }
<a name="l00041"></a>00041 
<a name="l00042"></a>00042     <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00043"></a>00043 }
<a name="l00044"></a>00044 
<a name="l00045"></a><a class="code" href="class_world.html#a51b30c67551fb563d87d99d28d0fd6c6">00045</a> <span class="keywordtype">void</span> <a class="code" href="class_world.html#a51b30c67551fb563d87d99d28d0fd6c6">World::moveScreen</a>(<a class="code" href="types_8hpp.html#a91ad9478d81a7aaf2593e8d9c3d06a14">uint</a> x, <a class="code" href="types_8hpp.html#a91ad9478d81a7aaf2593e8d9c3d06a14">uint</a> y, <a class="code" href="types_8hpp.html#a91ad9478d81a7aaf2593e8d9c3d06a14">uint</a> scale) {
<a name="l00046"></a>00046 
<a name="l00047"></a>00047 }
<a name="l00048"></a>00048 
<a name="l00049"></a><a class="code" href="class_world.html#aac8c1fde63c06577ffc648aaefdb37f0">00049</a> <span class="keywordtype">void</span> <a class="code" href="class_world.html#aac8c1fde63c06577ffc648aaefdb37f0">World::update</a>() {
<a name="l00050"></a>00050     <span class="comment">//Move those Creatures!</span>
<a name="l00051"></a>00051     <span class="keywordflow">for</span> (<a class="code" href="types_8hpp.html#a91ad9478d81a7aaf2593e8d9c3d06a14">uint</a> i = 0; i &lt; <a class="code" href="class_world.html#a42483905f9b8454a61292868d29a8843">m_nCreature</a>; i++) {
<a name="l00052"></a>00052         <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_creature.html#aee07784fade6640a4dbdc837397b6b5b">move</a>();
<a name="l00053"></a>00053     }
<a name="l00054"></a>00054 
<a name="l00055"></a>00055 }
<a name="l00056"></a>00056 
<a name="l00057"></a><a class="code" href="class_world.html#a7fa844c028cf185a5f90359cceeabf7c">00057</a> <span class="keywordtype">void</span> <a class="code" href="class_world.html#a7fa844c028cf185a5f90359cceeabf7c">World::paint</a>() {
<a name="l00058"></a>00058     glClearColor(1.0f, 1.0f, 1.0f, 1.0f); <span class="comment">// Clear the background of our window to white</span>
<a name="l00059"></a>00059     glClear(GL_COLOR_BUFFER_BIT); <span class="comment">//Clear the colour buffer (more buffers later on)</span>
<a name="l00060"></a>00060     glLoadIdentity(); <span class="comment">// Load the Identity Matrix to reset our drawing locations</span>
<a name="l00061"></a>00061 
<a name="l00062"></a>00062     <span class="comment">//drawCrap();</span>
<a name="l00063"></a>00063 
<a name="l00064"></a>00064     <span class="keywordflow">for</span> (<a class="code" href="types_8hpp.html#a91ad9478d81a7aaf2593e8d9c3d06a14">uint</a> i = 0; i &lt; <a class="code" href="class_world.html#a42483905f9b8454a61292868d29a8843">m_nCreature</a>; i++) {
<a name="l00065"></a>00065         <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_creature.html#a4e16b04f8a7a0fb76d1da13a671a3d2a">paint</a>();
<a name="l00066"></a>00066     }
<a name="l00067"></a>00067     <a class="code" href="class_world.html#a1b037e6b00d93bac9ec7db5a1217e4fc">applyCollision</a>();
<a name="l00068"></a>00068 
<a name="l00069"></a>00069     <span class="comment">//glFlush();    // Single Buffer Flush</span>
<a name="l00070"></a>00070     glutSwapBuffers(); <span class="comment">// Swap the OpenGL Double buffers to the window</span>
<a name="l00071"></a>00071 }
<a name="l00072"></a>00072 
<a name="l00073"></a><a class="code" href="class_world.html#aec128c792d233ed624adfc926a3d9744">00073</a> <a class="code" href="class_creature.html">Creature</a> * <a class="code" href="class_world.html#aec128c792d233ed624adfc926a3d9744">World::getCreatures</a> () {
<a name="l00074"></a>00074     <span class="keywordflow">return</span> <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>;
<a name="l00075"></a>00075 }
<a name="l00076"></a>00076 
<a name="l00077"></a><a class="code" href="class_world.html#a77967920dfc8db42cec61466e92d3404">00077</a> <span class="keywordtype">void</span> <a class="code" href="class_world.html#a77967920dfc8db42cec61466e92d3404">World::saveCreature</a> (<a class="code" href="types_8hpp.html#a91ad9478d81a7aaf2593e8d9c3d06a14">uint</a> index, <span class="keyword">const</span> <span class="keywordtype">char</span> * filename) {
<a name="l00078"></a>00078 
<a name="l00079"></a>00079 }
<a name="l00080"></a>00080 
<a name="l00081"></a><a class="code" href="class_world.html#a7f25ed25bcc5ec8f5947c0fd31e8be4d">00081</a> <span class="keywordtype">void</span> <a class="code" href="class_world.html#a7f25ed25bcc5ec8f5947c0fd31e8be4d">World::loadCreature</a> (<a class="code" href="types_8hpp.html#a91ad9478d81a7aaf2593e8d9c3d06a14">uint</a> index, <span class="keyword">const</span> <span class="keywordtype">char</span> * filename) {
<a name="l00082"></a>00082 
<a name="l00083"></a>00083 }
<a name="l00084"></a>00084 
<a name="l00085"></a><a class="code" href="class_world.html#a1b037e6b00d93bac9ec7db5a1217e4fc">00085</a> <span class="keywordtype">void</span> <a class="code" href="class_world.html#a1b037e6b00d93bac9ec7db5a1217e4fc">World::applyCollision</a>() {
<a name="l00086"></a>00086     <span class="comment">//Collision Detection Algorithm</span>
<a name="l00087"></a>00087     <span class="keywordflow">for</span> ( <a class="code" href="types_8hpp.html#a91ad9478d81a7aaf2593e8d9c3d06a14">uint</a> i = 0; i &lt; <a class="code" href="class_world.html#a42483905f9b8454a61292868d29a8843">m_nCreature</a>; i++)
<a name="l00088"></a>00088     {
<a name="l00089"></a>00089         <span class="comment">//Collision with other creatures</span>
<a name="l00090"></a>00090         <span class="keywordflow">for</span> (<a class="code" href="types_8hpp.html#a91ad9478d81a7aaf2593e8d9c3d06a14">uint</a> j = i+1; j &lt; <a class="code" href="class_world.html#a42483905f9b8454a61292868d29a8843">m_nCreature</a>; j++)
<a name="l00091"></a>00091         {
<a name="l00092"></a>00092             <a class="code" href="structs__kinematic.html">s_kinematic</a> * kin1 = <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>();
<a name="l00093"></a>00093             <a class="code" href="structs__kinematic.html">s_kinematic</a> * kin2 = <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[j].<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>();
<a name="l00094"></a>00094             <a class="code" href="structs__vector.html">s_vector</a> collisionCourse = (kin1-&gt;<a class="code" href="structs__kinematic.html#a2372849d2bc4e337ccfc9b48236a3d3a">pos</a> + kin1-&gt;<a class="code" href="structs__kinematic.html#a2ec4f506d737782910bf9d161acbefa8">vel</a>) - (kin2-&gt;<a class="code" href="structs__kinematic.html#a2372849d2bc4e337ccfc9b48236a3d3a">pos</a> + kin2-&gt;<a class="code" href="structs__kinematic.html#a2ec4f506d737782910bf9d161acbefa8">vel</a>);
<a name="l00095"></a>00095             <span class="keywordflow">if</span> (<a class="code" href="gl_helper_8hpp.html#a0e15415718a6e1b6bb503e99e3e3f1f6">getMag</a>(collisionCourse) &lt; <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#ae41a90d5f2c9fb4a3252565396f6b738">getRadius</a>() + <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[j].<a class="code" href="class_object.html#ae41a90d5f2c9fb4a3252565396f6b738">getRadius</a>() )
<a name="l00096"></a>00096             {
<a name="l00097"></a>00097                 <span class="comment">//collided</span>
<a name="l00098"></a>00098                 <span class="comment">//cout&lt;&lt;&quot;Collided(&quot;&lt;&lt;i&lt;&lt;&quot;,&quot;&lt;&lt;j&lt;&lt;&quot;): &quot;</span>
<a name="l00099"></a>00099                     <span class="comment">//&lt;&lt;getMag(collisionCourse)</span>
<a name="l00100"></a>00100                     <span class="comment">//&lt;&lt;&quot; &quot;&lt;&lt; m_creatures[i].getRadius() + m_creatures[j].getRadius() &lt;&lt; endl;</span>
<a name="l00101"></a>00101 
<a name="l00102"></a>00102                 <span class="comment">//Process only the orthogonal component</span>
<a name="l00103"></a>00103 
<a name="l00104"></a>00104                 <span class="comment">//first get the scalefactor from</span>
<a name="l00105"></a>00105                 <span class="keywordtype">float</span> scaleFactor = <a class="code" href="gl_helper_8hpp.html#acda2c0df466197df16279cde740ead0f">dotProduct</a>(<a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].getKinematic()-&gt;vel, collisionCourse) /
<a name="l00106"></a>00106                                     <a class="code" href="gl_helper_8hpp.html#a0e15415718a6e1b6bb503e99e3e3f1f6">getMag</a>(collisionCourse) /
<a name="l00107"></a>00107                                     <a class="code" href="gl_helper_8hpp.html#a0e15415718a6e1b6bb503e99e3e3f1f6">getMag</a>(collisionCourse);
<a name="l00108"></a>00108                 <a class="code" href="structs__vector.html">s_vector</a> i_ortho = scaleFactor * collisionCourse;
<a name="l00109"></a>00109                 <a class="code" href="structs__vector.html">s_vector</a> i_para = <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2ec4f506d737782910bf9d161acbefa8">vel</a> - i_ortho;
<a name="l00110"></a>00110                 collisionCourse = -1.0 * collisionCourse;
<a name="l00111"></a>00111                 scaleFactor = <a class="code" href="gl_helper_8hpp.html#acda2c0df466197df16279cde740ead0f">dotProduct</a>(<a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[j].getKinematic()-&gt;vel, collisionCourse) /
<a name="l00112"></a>00112                                     <a class="code" href="gl_helper_8hpp.html#a0e15415718a6e1b6bb503e99e3e3f1f6">getMag</a>(collisionCourse) /
<a name="l00113"></a>00113                                     <a class="code" href="gl_helper_8hpp.html#a0e15415718a6e1b6bb503e99e3e3f1f6">getMag</a>(collisionCourse);
<a name="l00114"></a>00114                 <a class="code" href="structs__vector.html">s_vector</a> j_ortho = scaleFactor * collisionCourse;
<a name="l00115"></a>00115                 <a class="code" href="structs__vector.html">s_vector</a> j_para = <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[j].<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2ec4f506d737782910bf9d161acbefa8">vel</a> - j_ortho;
<a name="l00116"></a>00116                 <a class="code" href="structs__vector.html">s_vector</a> tmp = j_ortho;
<a name="l00117"></a>00117                 j_ortho = i_ortho;
<a name="l00118"></a>00118                 i_ortho = tmp;
<a name="l00119"></a>00119 
<a name="l00120"></a>00120                 i_para = i_para + i_ortho;
<a name="l00121"></a>00121                 j_para = j_para + j_ortho;
<a name="l00122"></a>00122 
<a name="l00123"></a>00123                 <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2ec4f506d737782910bf9d161acbefa8">vel</a> = i_para;
<a name="l00124"></a>00124                 <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[j].<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2ec4f506d737782910bf9d161acbefa8">vel</a> = j_para;
<a name="l00125"></a>00125             }
<a name="l00126"></a>00126         }
<a name="l00127"></a>00127 
<a name="l00128"></a>00128         <span class="comment">//Collision with the walls</span>
<a name="l00129"></a>00129         <span class="keywordflow">if</span>(<a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].getKinematic()-&gt;pos.x - <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#ae41a90d5f2c9fb4a3252565396f6b738">getRadius</a>() &lt; 0){
<a name="l00130"></a>00130             <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2ec4f506d737782910bf9d161acbefa8">vel</a>.<a class="code" href="structs__vector.html#a5f391a150c90caba95e29898f47e4343">x</a> *= -1.0f;
<a name="l00131"></a>00131             <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2372849d2bc4e337ccfc9b48236a3d3a">pos</a>.<a class="code" href="structs__vector.html#a5f391a150c90caba95e29898f47e4343">x</a> = <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#ae41a90d5f2c9fb4a3252565396f6b738">getRadius</a>() + 0.01f;
<a name="l00132"></a>00132         }<span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].getKinematic()-&gt;pos.x + <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#ae41a90d5f2c9fb4a3252565396f6b738">getRadius</a>() &gt; <a class="code" href="class_world.html#a189b065d93b1ec9055065fea18aa9961">m_xSize</a>){
<a name="l00133"></a>00133             <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2ec4f506d737782910bf9d161acbefa8">vel</a>.<a class="code" href="structs__vector.html#a5f391a150c90caba95e29898f47e4343">x</a> *= -1.0f;
<a name="l00134"></a>00134             <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2372849d2bc4e337ccfc9b48236a3d3a">pos</a>.<a class="code" href="structs__vector.html#a5f391a150c90caba95e29898f47e4343">x</a> = <a class="code" href="class_world.html#a189b065d93b1ec9055065fea18aa9961">m_xSize</a> - <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#ae41a90d5f2c9fb4a3252565396f6b738">getRadius</a>() - 0.01f;
<a name="l00135"></a>00135         }
<a name="l00136"></a>00136         <span class="keywordflow">if</span>(<a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].getKinematic()-&gt;pos.y - <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#ae41a90d5f2c9fb4a3252565396f6b738">getRadius</a>() &lt; 0){
<a name="l00137"></a>00137             <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2ec4f506d737782910bf9d161acbefa8">vel</a>.<a class="code" href="structs__vector.html#a38d7ef8912bdd7a9146e6a560fe500d3">y</a> *= -1.0f;
<a name="l00138"></a>00138             <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2372849d2bc4e337ccfc9b48236a3d3a">pos</a>.<a class="code" href="structs__vector.html#a38d7ef8912bdd7a9146e6a560fe500d3">y</a> = <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#ae41a90d5f2c9fb4a3252565396f6b738">getRadius</a>() + 0.01f;
<a name="l00139"></a>00139         }<span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].getKinematic()-&gt;pos.y + <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#ae41a90d5f2c9fb4a3252565396f6b738">getRadius</a>() &gt; <a class="code" href="class_world.html#a7e13242f5970ab45bd6b992c8987d972">m_ySize</a>){
<a name="l00140"></a>00140             <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2ec4f506d737782910bf9d161acbefa8">vel</a>.<a class="code" href="structs__vector.html#a38d7ef8912bdd7a9146e6a560fe500d3">y</a> *= -1.0f;
<a name="l00141"></a>00141             <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#a6e06f467ee7f36a5dc067ff698022702">getKinematic</a>()-&gt;<a class="code" href="structs__kinematic.html#a2372849d2bc4e337ccfc9b48236a3d3a">pos</a>.<a class="code" href="structs__vector.html#a38d7ef8912bdd7a9146e6a560fe500d3">y</a> = <a class="code" href="class_world.html#a7e13242f5970ab45bd6b992c8987d972">m_ySize</a> - <a class="code" href="class_world.html#a83dbea29b17661c6ca0252e82e932b1e">m_creatures</a>[i].<a class="code" href="class_object.html#ae41a90d5f2c9fb4a3252565396f6b738">getRadius</a>() - 0.01f;
<a name="l00142"></a>00142         }
<a name="l00143"></a>00143     }
<a name="l00144"></a>00144     <span class="comment">//-----------------------------*/</span>
<a name="l00145"></a>00145 }
</pre></div></div><!-- contents -->


<hr class="footer"/><address class="footer"><small>
Generated on Fri Apr 20 2012 21:57:14 for junglego by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.0
</small></address>

</body>
</html>
